﻿/*  ----------------------------------------------------------------------------
 *  DES-Release 2
 *  ----------------------------------------------------------------------------
 *  File:       AssemblyLoader.cs
 *  Author:     nitinkoshy@gmail.com
 *  Source:     http://des.codeplex.com/
 *  ----------------------------------------------------------------------------
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Configuration;
using System.Diagnostics;
using System.Security.Principal;
using System.Security.Policy;
using System.Runtime.Remoting;

namespace DES.Server.Service.Helpers
{
    [Serializable]
    public class AssemblyLoader : MarshalByRefObject
    {
        public Object LoadAndRun(string assemblyName, string typeName)
        {
            Assembly _assembly = Assembly.Load(assemblyName);
            Type _type = _assembly.GetType(typeName);
            MethodInfo _method = _type.GetMethod("Execute");
            return _method.Invoke(Activator.CreateInstance(_type), null);
        }
    }
}
